﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace _EF返回DateSet
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        DataHelper dh = new DataHelper();

        private void Form1_Load(object sender, EventArgs e)
        {
            SqlParameter[] para = { 
                                  new SqlParameter("@Name","zhangsan"),
                                  new SqlParameter("@ParentId",1),
                                  new SqlParameter("@TableName","hehe")
                                  };
            DataSet ds = dh.GetDataSet("exec Pro_GetDataSet", para);
            datagv1.DataSource = ds.Tables[0];
            datagv2.DataSource = ds.Tables[1];
        }

        public string tableName = "";

        private void btnQh_Click(object sender, EventArgs e)
        {
            if (tableName == "BaseUser")
            {
                tableName = "BaseMenu";
            }
            else
            {
                tableName = "BaseUser";
            }
            SqlParameter[] para = { 
                                  new SqlParameter("@Name","zhangsan"),
                                  new SqlParameter("@ParentId",1),
                                  new SqlParameter("@TableName",tableName)
                                  };
            DataTable dt = dh.GetDataTable("exec Pro_GetDataSet", para);
            datagv3.DataSource = dt;

        }

        DataTable StaticTable;

        private void btnXs_Click(object sender, EventArgs e)
        {
            tableName = "BaseUser";
            SqlParameter[] para = { 
                                  new SqlParameter("@Name","zhangsan"),
                                  new SqlParameter("@ParentId",1),
                                  new SqlParameter("@TableName",tableName)
                                  };
            DataTable dt = dh.GetDataTable("exec Pro_GetDataSet", para);
            datagv3.DataSource = dt;
            StaticTable = dt;
        }

        private void btnTest_Click(object sender, EventArgs e)
        {
            TableToEntity.GetEntity(StaticTable);
        }
    }
}
